package com.server.user;

import com.dao.user.RecordMapper;
import com.model.pojo.RepCode;
import com.model.pojo.RepEntity;
import com.util.GetTokenData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class RecodeService {
    @Autowired
    RecordMapper recordMapper;
    @Autowired
    GetTokenData getTokenData;

    public RepEntity getChartRecord(String token){
        Map<String, String> resultMap = getTokenData.getTokenData(token);
        int userId = Integer.parseInt(resultMap.get("id"));
        return new RepEntity(RepCode.success, recordMapper.chartsRecode(userId));
    }

    public RepEntity getDashRecord(String token){
        Map<String, String> resultMap = getTokenData.getTokenData(token);
        int userId = Integer.parseInt(resultMap.get("id"));
        return new RepEntity(RepCode.success, recordMapper.DashRecode(userId));
    }
}
